{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f93ca6b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import ast\n",
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "a805606a",
   "metadata": {},
   "outputs": [],
   "source": [
    "list_a=np.arange(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "dbda951a",
   "metadata": {},
   "outputs": [],
   "source": [
    "p1=pd.read_csv(\"award.csv\",low_memory=False,usecols=list_a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "cb137b41",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>奖学金名称</th>\n",
       "      <th>奖学金类型</th>\n",
       "      <th>奖励等级</th>\n",
       "      <th>评定学年</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>['', '本科优秀学生奖学金', '本科优秀学生奖学金', '本科优秀学生奖学金']</td>\n",
       "      <td>['', '学校奖学金', '学校奖学金', '学校奖学金']</td>\n",
       "      <td>['', '三等奖学金', '三等奖学金', '三等奖学金']</td>\n",
       "      <td>['', '2018-2019学年', '2019-2020学年', '2020-2021学年']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>['', '本科优秀学生奖学金', '本科优秀学生奖学金']</td>\n",
       "      <td>['', '学校奖学金', '学校奖学金']</td>\n",
       "      <td>['', '三等奖学金', '二等奖学金']</td>\n",
       "      <td>['', '2019-2020学年', '2020-2021学年']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>['', '本科优秀学生奖学金']</td>\n",
       "      <td>['', '学校奖学金']</td>\n",
       "      <td>['', '三等奖学金']</td>\n",
       "      <td>['', '2018-2019学年']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>['']</td>\n",
       "      <td>['']</td>\n",
       "      <td>['']</td>\n",
       "      <td>['']</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>['', '本科优秀学生奖学金', '本科优秀学生奖学金', '本科优秀学生奖学金']</td>\n",
       "      <td>['', '学校奖学金', '学校奖学金', '学校奖学金']</td>\n",
       "      <td>['', '一等奖学金', '一等奖学金', '二等奖学金']</td>\n",
       "      <td>['', '2018-2019学年', '2019-2020学年', '2020-2021学年']</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0                                        奖学金名称  \\\n",
       "0           0  ['', '本科优秀学生奖学金', '本科优秀学生奖学金', '本科优秀学生奖学金']   \n",
       "1           1               ['', '本科优秀学生奖学金', '本科优秀学生奖学金']   \n",
       "2           2                            ['', '本科优秀学生奖学金']   \n",
       "3           3                                         ['']   \n",
       "4           4  ['', '本科优秀学生奖学金', '本科优秀学生奖学金', '本科优秀学生奖学金']   \n",
       "\n",
       "                             奖学金类型                             奖励等级  \\\n",
       "0  ['', '学校奖学金', '学校奖学金', '学校奖学金']  ['', '三等奖学金', '三等奖学金', '三等奖学金']   \n",
       "1           ['', '学校奖学金', '学校奖学金']           ['', '三等奖学金', '二等奖学金']   \n",
       "2                    ['', '学校奖学金']                    ['', '三等奖学金']   \n",
       "3                             ['']                             ['']   \n",
       "4  ['', '学校奖学金', '学校奖学金', '学校奖学金']  ['', '一等奖学金', '一等奖学金', '二等奖学金']   \n",
       "\n",
       "                                                评定学年  \n",
       "0  ['', '2018-2019学年', '2019-2020学年', '2020-2021学年']  \n",
       "1                 ['', '2019-2020学年', '2020-2021学年']  \n",
       "2                                ['', '2018-2019学年']  \n",
       "3                                               ['']  \n",
       "4  ['', '2018-2019学年', '2019-2020学年', '2020-2021学年']  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "p1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "52c61eb4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ca843e54",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "True\n",
      "1\n"
     ]
    }
   ],
   "source": [
    "t=ast.literal_eval(p1[\"评定学年\"][3])\n",
    "print(t[0]==\"\")\n",
    "print(len(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "7d472d69",
   "metadata": {},
   "outputs": [],
   "source": [
    "g=p1[\"Unnamed: 0\"][0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "1019abe6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "g"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "468243f4",
   "metadata": {},
   "source": [
    "g"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "fcb4b584",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'学生': 0, '类型': '一等奖'}]"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "firstyear=[]\n",
    "dict={}\n",
    "dict[\"学生\"]=0\n",
    "dict[\"类型\"]=\"一等奖\"\n",
    "firstyear.append(dict)\n",
    "firstyear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "5dc29399",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'评定学年'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3079\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3080\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '评定学年'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-45-149ba703ac2a>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      6\u001b[0m \u001b[1;31m# level=ast.literal_eval(p1[\"奖励等级\"][0])\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      7\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;36m6906\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m     \u001b[0myear\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mast\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mliteral_eval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"评定学年\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      9\u001b[0m \u001b[1;31m#     print(type(year))\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     10\u001b[0m     \u001b[0mtype\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mast\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mliteral_eval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"奖学金类型\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   3022\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3023\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3024\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3025\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3026\u001b[0m                 \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3080\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3082\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3083\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3084\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mtolerance\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '评定学年'"
     ]
    }
   ],
   "source": [
    "firstyear=[]\n",
    "secondyear=[]\n",
    "thirdyear=[]\n",
    "# year=ast.literal_eval(p1[\"评定学年\"][0])\n",
    "# type=ast.literal_eval(p1[\"奖学金类型\"][0])\n",
    "# level=ast.literal_eval(p1[\"奖励等级\"][0])\n",
    "for i in range(0,6906):\n",
    "    year=ast.literal_eval(p1[\"评定学年\"][i])\n",
    "#     print(type(year))\n",
    "    type=ast.literal_eval(p1[\"奖学金类型\"][i])\n",
    "    level=ast.literal_eval(p1[\"奖励等级\"][i])\n",
    "    number=p1[\"Unnamed: 0\"]\n",
    "    for j in range(0,len(year)):\n",
    "        firstdict={}\n",
    "        seconddict={}\n",
    "        thirddict={}\n",
    "        if year[j]==\"2018-2019学年\":\n",
    "            firstdict[\"学生\"]=number[i]\n",
    "            firstdict[\"类型\"]=type[j]+level[j]\n",
    "            firstyear.append(firstdict)\n",
    "        elif year[j]==\"2019-2020学年\":\n",
    "            seconddict[\"学生\"]=number[i]\n",
    "            seconddict[\"类型\"]=type[j]+level[j]\n",
    "            secondyear.append(seconddict)\n",
    "        elif year[j]==\"2020-2021学年\": \n",
    "            thirddict[\"学生\"]=number[i]\n",
    "            thirddict[\"类型\"]=type[j]+level[j]\n",
    "            thirdyear.append(thirddict)\n",
    "df1=pd.DataFrame(firstyear)\n",
    "print(df1)\n",
    "df2=pd.DataFrame(secondyear)\n",
    "print(df2)\n",
    "df3=pd.DataFrame(thirdyear)\n",
    "print(df3)\n",
    "df1.to_csv(\"18-19award.csv\")\n",
    "df2.to_csv(\"19-20award.csv\")\n",
    "df3.to_csv(\"20-21award.csv\")\n",
    "\n",
    "# print(firstyear)\n",
    "# print(secondyear)\n",
    "# print(thirdyear)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "688bff79",
   "metadata": {},
   "outputs": [],
   "source": [
    "df2.to_csv(\"19-20.csv\")\n",
    "df3.to_csv(\"20-21.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "61d40b0c",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1.to_csv(\"18-19n.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "66575001",
   "metadata": {},
   "outputs": [],
   "source": [
    "df1.to_csv(\"18-19award.csv\")\n",
    "df2.to_csv(\"19-20award.csv\")\n",
    "df3.to_csv(\"20-21award.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "f00b9945",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "list.remove(x): x not in list",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-34-8d4917e942a4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m     28\u001b[0m             \u001b[0mfirstyear\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mfirstdict\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     29\u001b[0m         \u001b[1;32melif\u001b[0m \u001b[0myear\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mj\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;34m\"2019-2020学年\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 30\u001b[1;33m             \u001b[0mtick\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mremove\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     31\u001b[0m             \u001b[0mseconddict\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"学生\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mnumber\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     32\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mj\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;34m\"\"\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mValueError\u001b[0m: list.remove(x): x not in list"
     ]
    }
   ],
   "source": [
    "firstyear=[]\n",
    "secondyear=[]\n",
    "thirdyear=[]\n",
    "# year=ast.literal_eval(p1[\"评定学年\"][0])\n",
    "# type=ast.literal_eval(p1[\"奖学金类型\"][0])\n",
    "# level=ast.literal_eval(p1[\"奖励等级\"][0])\n",
    "for i in range(0,6906):\n",
    "    year=ast.literal_eval(p1[\"评定学年\"][i])\n",
    "    type=ast.literal_eval(p1[\"奖学金类型\"][i])\n",
    "    level=ast.literal_eval(p1[\"奖励等级\"][i])\n",
    "    number=p1[\"Unnamed: 0\"]\n",
    "    tick=[1,2,3]\n",
    "#     tick.remove(1)\n",
    "#     print(tick[0])\n",
    "\n",
    "    for j in range(0,len(year)):\n",
    "        firstdict={}\n",
    "        seconddict={}\n",
    "        thirddict={}\n",
    "        \n",
    "        if year[j]==\"2018-2019学年\":\n",
    "            tick.remove(1)\n",
    "            firstdict[\"学生\"]=number[i]\n",
    "            if type[j]==\"\":\n",
    "                firstdict[\"类型\"]=\"无\"\n",
    "            elif type[j]!=\"\":\n",
    "                firstdict[\"类型\"]=type[j]+level[j]\n",
    "            firstyear.append(firstdict)\n",
    "        elif year[j]==\"2019-2020学年\":\n",
    "            tick.remove(2)\n",
    "            seconddict[\"学生\"]=number[i]\n",
    "            if type[j]==\"\":\n",
    "                seconddict[\"类型\"]=\"无\"\n",
    "            elif type[j]!=\"\":\n",
    "                seconddict[\"类型\"]=type[j]+level[j]\n",
    "            secondyear.append(seconddict)\n",
    "        elif year[j]==\"2020-2021学年\": \n",
    "            tick.remove(3)\n",
    "            thirddict[\"学生\"]=number[i]\n",
    "            if type[j]==\"\":\n",
    "                thirddict[\"类型\"]=\"无\"\n",
    "            elif type[j]!=\"\":\n",
    "                thirddict[\"类型\"]=type[j]+level[j]\n",
    "            thirdyear.append(thirddict)\n",
    "    for k in range(0,len(tick)):\n",
    "        if tick[k]==1:\n",
    "            firstdict[\"学生\"]=number[i]\n",
    "            firstdict[\"类型\"]=\"无\" \n",
    "            firstyear.append(firstdict)\n",
    "        elif tick[k]==2:\n",
    "            seconddict[\"学生\"]=number[i]\n",
    "            seconddict[\"类型\"]=\"无\" \n",
    "            secondyear.append(seconddict)\n",
    "        elif tick[k]==3:\n",
    "            thirddict[\"学生\"]=number[i]\n",
    "            thirddict[\"类型\"]=\"无\" \n",
    "            thirdyear.append(thirddict)\n",
    "df1=pd.DataFrame(firstyear)\n",
    "print(df1)\n",
    "df2=pd.DataFrame(secondyear)\n",
    "print(df2)\n",
    "df3=pd.DataFrame(thirdyear)\n",
    "print(df3)\n",
    "df1.to_csv(\"18-19award_update3.csv\")\n",
    "df2.to_csv(\"19-20award_update3.csv\")\n",
    "df3.to_csv(\"20-21award_update3.csv\")\n",
    "\n",
    "# print(firstyear)\n",
    "# print(secondyear)\n",
    "# print(thirdyear)\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "56e19040",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyError",
     "evalue": "'奖学金类型'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3079\u001b[0m             \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3080\u001b[1;33m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\index.pyx\u001b[0m in \u001b[0;36mpandas._libs.index.IndexEngine.get_loc\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;32mpandas\\_libs\\hashtable_class_helper.pxi\u001b[0m in \u001b[0;36mpandas._libs.hashtable.PyObjectHashTable.get_item\u001b[1;34m()\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '奖学金类型'",
      "\nThe above exception was the direct cause of the following exception:\n",
      "\u001b[1;31mKeyError\u001b[0m                                  Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-50-48820c35c6f6>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtype3\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mast\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mliteral_eval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mp1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"奖学金类型\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      2\u001b[0m \u001b[0mtype\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m==\u001b[0m\u001b[1;34m\"\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\frame.py\u001b[0m in \u001b[0;36m__getitem__\u001b[1;34m(self, key)\u001b[0m\n\u001b[0;32m   3022\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnlevels\u001b[0m \u001b[1;33m>\u001b[0m \u001b[1;36m1\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3023\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_getitem_multilevel\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3024\u001b[1;33m             \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcolumns\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3025\u001b[0m             \u001b[1;32mif\u001b[0m \u001b[0mis_integer\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3026\u001b[0m                 \u001b[0mindexer\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[0mindexer\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32m~\\anaconda3\\lib\\site-packages\\pandas\\core\\indexes\\base.py\u001b[0m in \u001b[0;36mget_loc\u001b[1;34m(self, key, method, tolerance)\u001b[0m\n\u001b[0;32m   3080\u001b[0m                 \u001b[1;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_engine\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mget_loc\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mcasted_key\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3081\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyError\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m-> 3082\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mkey\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[0merr\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m   3083\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m   3084\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[0mtolerance\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyError\u001b[0m: '奖学金类型'"
     ]
    }
   ],
   "source": [
    "type3=ast.literal_eval(p1[\"奖学金类型\"][i])\n",
    "type[0]==\"\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "39be2e20",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 3]"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "asda=[1,2,3]\n",
    "asda"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "643914f2",
   "metadata": {},
   "outputs": [],
   "source": [
    "asda.remove(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "304b11cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 3]"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "asda"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "fc9617a3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "asda[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c774a080",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>学生</th>\n",
       "      <th>类型</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>学校奖学金三等奖学金</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>学校奖学金三等奖学金</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>4</td>\n",
       "      <td>学校奖学金一等奖学金</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>6</td>\n",
       "      <td>国家奖学金不分等级</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>7</td>\n",
       "      <td>学校奖学金三等奖学金</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0  学生          类型\n",
       "0           0   0  学校奖学金三等奖学金\n",
       "1           1   2  学校奖学金三等奖学金\n",
       "2           2   4  学校奖学金一等奖学金\n",
       "3           3   6   国家奖学金不分等级\n",
       "4           4   7  学校奖学金三等奖学金"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "import ast\n",
    "import re\n",
    "list_a=np.arange(3)\n",
    "p1=pd.read_csv(\"18-19award.csv\",low_memory=False,usecols=list_a)\n",
    "p1.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "9a73d0ec",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'Series' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-43-fddca67360a0>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mer\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mp1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"学生\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m1\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mtype2\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mp1\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m\"类型\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'Series' object is not callable"
     ]
    }
   ],
   "source": [
    "t=p1[\"学生\"]\n",
    "er=p1[\"学生\"][1]\n",
    "type2=p1[\"类型\"]\n",
    "print(type(t))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "2f9d12e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import requests\n",
    "d=[1,2]\n",
    "5 in d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "b481245c",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'Series' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-34-84ebfad5ad69>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0md\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m: 'Series' object is not callable"
     ]
    }
   ],
   "source": [
    "print(type(d))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "5e1e33a5",
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "'Series' object is not callable",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-52-85d304905f6c>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mrange\u001b[0m \u001b[1;33m(\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m     \u001b[0mstudent\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mt\u001b[0m\u001b[1;33m[\u001b[0m\u001b[0mi\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 5\u001b[1;33m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtype\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mstudent\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      6\u001b[0m \u001b[1;36m1\u001b[0m \u001b[1;32min\u001b[0m \u001b[0mstudent\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: 'Series' object is not callable"
     ]
    }
   ],
   "source": [
    "t=p1[\"学生\"]\n",
    "student=[]\n",
    "for i in range (0,len(t)):\n",
    "    student.append(t[i])\n",
    "print(type(student))\n",
    "1 in student"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
